﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using umbraco.BusinessLogic.Actions;
using umbraco.cms.businesslogic.web;
using umbraco.cms.businesslogic.property;
using umbraco.interfaces;
using umbraco.NodeFactory;

namespace ExtendedWorkFlow.Commands
{

    public class Publish : IExtendedWorkFlowCommand
    {

        public bool RunCommand(string Parameters, Node Command, WorkFlow ExtendedWorkFlow)
        {
            try
            {
                ParameterCollection colParameters = Functions.GetParameters(Parameters);

                if (colParameters["deep"].Value == "1")
                    return ExtendedWorkFlow.Document.PublishWithChildrenWithResult(umbraco.BusinessLogic.User.GetCurrent());
                else
                    return ExtendedWorkFlow.Document.PublishWithResult(umbraco.BusinessLogic.User.GetCurrent());
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.ToString());
            }

            return false;
        }

    }

}
